﻿//  Created by Mathew Purchase.
//  Copyright (c) 2014 Mathew Purchase. All rights reserved.

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class UIService : MonoBehaviour 
{

	//---------------------------------------------------------------------------------------------
	// Properties

	
	
	//---------------------------------------------------------------------------------------------
	// Members
	
	public Character m_playerMain;
	public GameObject m_settlementUI;
	public GameObject m_navigationUI;
	public GameObject m_introUI;
	public GameObject m_randomEventUI;
	public GameObject m_inventoryUI;
	
	//---------------------------------------------------------------------------------------------
	// Events and Delegates
	
	
	//---------------------------------------------------------------------------------------------
	// Init
	
	void Start () 
	{
		UISwitch(m_introUI);
		terrainGeneration.ready += LoadingScreen;
		RandomEventService.doEvent += EventScreen;
		Character.playerInSettlement += SettlementScreen;
	}
	
	void OnDisable ()
	{
		terrainGeneration.ready -= LoadingScreen;
		RandomEventService.doEvent -= EventScreen;
		Character.playerInSettlement -= SettlementScreen;
	}
	
	//---------------------------------------------------------------------------------------------
	// Core Functions

	void Update () 
	{
		
	}
	//---------------------------------------------------------------------------------------------
	
	void UISwitch(GameObject SwitchTo)
	{
		
		m_settlementUI.SetActive(false);
		m_navigationUI.SetActive(false);
		m_introUI.SetActive(false);
		m_randomEventUI.SetActive(false);
		m_inventoryUI.SetActive(false);
	
		SwitchTo.SetActive(true);
	}
	
	
	
	//---------------------------------------------------------------------------------------------
	
	void LoadingScreen ()
	{
		UISwitch(m_navigationUI);
	}
	//---------------------------------------------------------------------------------------------
	
	void EventScreen ()
	{
		UISwitch(m_randomEventUI);
	}
	//---------------------------------------------------------------------------------------------
	
	void SettlementScreen()
	{
		UISwitch(m_settlementUI);
	}
	
}
